﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Odds.Entity;
using Odds.DBUtility;
using System.Data;
using System.Data.SqlClient;

namespace Odds.DataAccess
{
    public class OddsIssueHtmlController
    {
        private string SQL_INSERT = string.Format("INSERT INTO OddsIssueHtml(IssueHtmlID,{0},{1},{2}) VALUES(NEWID(),@{0},@{1},@{2})",
            PARM_ODDSISSUEREALID,PARM_ODDSISSUEURL,PARM_ODDSISSUEHTML);

        
        private const string PARM_ODDSISSUEREALID = "IssueRealID";
        private const string PARM_ODDSISSUEURL = "IssueUrl";
        private const string PARM_ODDSISSUEHTML = "IssueHtml";        

        public bool Insert(OddsIssueHtml oddsIssueHtml)
        {
            bool result = false;
            try 
            {
                SqlParameter[] parm = {
                                            new SqlParameter("@" + PARM_ODDSISSUEREALID, oddsIssueHtml.IssueRealID),
                                            new SqlParameter("@" + PARM_ODDSISSUEURL, oddsIssueHtml.IssueUrl),
                                            new SqlParameter("@" + PARM_ODDSISSUEHTML, oddsIssueHtml.IssueHtml)
                                      };
                OddsSQLHelper.ExecuteNonQuery(CommandType.StoredProcedure, "Pro_OddsIssueHtmlInsert", parm);
                result = true;
            }
            catch (Exception e) 
            { 
                throw e; 
            }
            return result;
        }
    }
}
